<%
    String contextPath = request.getContextPath();
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>DORMS宿舍管理系统-系统管理员</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
        }
        .header {
            background-color: #007BFF;
            color: white;
            padding: 10px;
            text-align: center;
        }
        .sidebar1 {
            width: 200px;
            background-color: #f8f9fa;
            float: left;
            height: 100vh;
            padding-top: 20px;
        }
        .sidebar1 a {
            display: block;
            padding: 10px;
            text-decoration: none;
            color: black;
        }
        .sidebar1 a:hover {
            background-color: #ddd;
        }
        .sidebar {
            height: 100vh; /* 使侧边栏高度占满整个视口高度 */
            width: 200px;
            float: left;
            background-color: #f4f4f4;
            padding-top: 20px; /* 增加内边距，使内容不贴边 */
            box-sizing: border-box; /* 确保内边距和边框包含在元素的总宽度和高度内 */
        }
        .sidebar a {
            display: block;
            padding: 15px; /* 增加内边距 */
            text-decoration: none;
            color: #333;
            font-size: 18px; /* 增大字体大小 */
        }
        .sidebar a:hover {
            background-color: #ddd;
        }
        .content {
            margin-left: 210px;
            padding: 20px;
        }
        table {
            width: 80%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
        }
        th {
            background-color: #f2f2f2;
        }
        .button {
            padding: 5px 15px;
            color: white;
            background-color: #4CAF50;
            border: none;
            cursor: pointer;
        }
        .button:hover {
            background-color: #45a049;
        }
    </style>

</head>
<body>
<jsp:include page="/nav.jsp"/>
<div class="content">
    <h1>DORMS宿舍管理系统-系统管理员</h1>
    <div>
        <form action="searchBuilding" method="get">
            <label for="field">字段：</label>
            <select id="field" name="field">
                <option value="BuildingID">ID</option>
                <option value="BuildingName">名称</option>
                <option value="Address">地址</option>
                <!-- Add more options as needed -->
            </select>
            <label for="value">值：</label>
            <input type="text" id="value" name="value">
            <input type="submit" value="开始搜索">
        </form>
        <a href="buildingAdd">添加楼宇信息</a>
    </div>
    <table>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>房间数</th>
            <th>管理员</th>
            <th>操作</th>
        </tr>
        <tbody>
        <c:forEach var="i" items="${requestScope.list}">
            <tr>
                <td>${i.buildingID}</td>
                <td>${i.buildingName}</td>
                <td>${i.totalRooms}</td>
                <td>${i.administrator}</td>
                <td>
                    <a href="<%=contextPath%>/buildingUpdate?id=${i.buildingID}" class="button">修改</a>
                    <a href="<%=contextPath%>/buildingDelete?id=${i.buildingID}" class="button">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<footer>
    <p>2025 © DORMS</p>
</footer>
</body>
</html>